package com.sanjiahantang.youjiarole.module.me.favorite.views.impl;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.sanjiahantang.plugin.swipemenulistview.SwipeMenuListView;
import com.sanjiahantang.youjiarole.R;
import com.sanjiahantang.youjiarole.base.BaseMvpFragment;
import com.sanjiahantang.youjiarole.module.me.favorite.presenters.FavoriteCasePresenter;
import com.sanjiahantang.youjiarole.module.me.favorite.views.FavoriteCaseView;


/**
 * Created by zy on 2017/9/5.
 */

public class FavoriteCaseFragment extends BaseMvpFragment<FavoriteCaseView,FavoriteCasePresenter> implements FavoriteCaseView {
    private View $view;
    private SwipeMenuListView lvCases;
    @Override
    public void showProgress() {
        context.showProgress(context);
    }

    @Override
    public void hideProgress() {
        context.hideProgress();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        if ($view != null) {
            ViewGroup parent = (ViewGroup) $view.getParent();
            if (parent != null) {
                parent.removeView($view);
            }
        } else {
            $view = inflater.inflate(R.layout.fragment_list, container, false);
        }
        return $view;
    }

    @Override
    public FavoriteCasePresenter initPresenter() {
        return new FavoriteCasePresenter();
    }

    @Override
    protected void initView() {
        lvCases = (SwipeMenuListView) $view.findViewById(R.id.lvCases);
        lvCases.setAdapter(presenter.getAdapter(context));
    }

    @Override
    protected void initData() {
        presenter.loadData(context);
    }
}
